package gemini.castor.ui.client.page.content.store.shoppingcart.shoppingcartview;

import gemini.castor.ui.client.page.content.store.shoppingcart.ShoppingCartItem;

import java.util.List;

import com.google.gwt.validation.client.interfaces.IValidatable;

public class ShoppingCartViewObject implements IValidatable {

	private List<ShoppingCartItem> items;

	private int monthlyPoint;
	private int discountScale;
	private String orderMonth;
	
	private int point;
	private int earnBase;
	private int retailPrice;
	private int discountedRetail;
	
	private String distributorCode;
	private String fullName;	

	public List<ShoppingCartItem> getItems() {
		return items;
	}

	public void setItems(List<ShoppingCartItem> items) {
		this.items = items;
	}

	public int getMonthlyPoint() {
		return monthlyPoint;
	}

	public void setMonthlyPoint(int monthlyPoint) {
		this.monthlyPoint = monthlyPoint;
	}

	public int getDiscountScale() {
		return discountScale;
	}

	public void setDiscountScale(int discountScale) {
		this.discountScale = discountScale;
	}

	public String getOrderMonth() {
		return orderMonth;
	}

	public void setOrderMonth(String orderMonth) {
		this.orderMonth = orderMonth;
	}

	public void setPoint(int point) {
		this.point = point;
	}

	public int getPoint() {
		return point;
	}

	public void setEarnBase(int earnBase) {
		this.earnBase = earnBase;
	}

	public int getEarnBase() {
		return earnBase;
	}

	public void setRetailPrice(int retailPrice) {
		this.retailPrice = retailPrice;
	}

	public int getRetailPrice() {
		return retailPrice;
	}

	public void setDiscountedRetail(int discountedRetail) {
		this.discountedRetail = discountedRetail;
	}

	public int getDiscountedRetail() {
		return discountedRetail;
	}

	public void recalculate() {
		point = 0;
		earnBase = 0;
		retailPrice = 0;
		discountedRetail = 0;
		
		if (items != null && !items.isEmpty()) {
			for (ShoppingCartItem it : items) {
				if (!it.isDeleted()) {
					point += it.getProduct().getVolumePoint()
							* it.getQuantity();
					earnBase += it.getProduct().getVolumePoint()
							* it.getQuantity();
					retailPrice += it.getProduct().getVolumePoint()
							* it.getQuantity();
				}
			}

			discountedRetail = retailPrice * (100 - discountScale) / 100;
		}
	}

	public void setDistributorCode(String distributorCode) {
		this.distributorCode = distributorCode;
	}

	public String getDistributorCode() {
		return distributorCode;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getFullName() {
		return fullName;
	}

}
